package com.yanqu.road.server.cmd.activity.zhenhuan.thirdProcess;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ZhenHuanProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.zhenhuan.ZhenHuanThirdProcessModule;
import com.yanqu.road.server.protocol.Protocol;

/**
 * 甄嬛三开宴
 */
@Cmd(code = Protocol.S_ZHENHUAN_THIRD_PROCESS_GET_ALL_USER, desc = "获取参赛成员信息")
public class ZhenHuanThirdProcessGetAllUserCmd extends AbstractCommand {

    private int activityId;

    private long targetUserId;


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ZhenHuanProto.ZhenHuanThirdProcessGetAllUserReqMsg reqMsg = ZhenHuanProto.ZhenHuanThirdProcessGetAllUserReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        targetUserId = reqMsg.getTargetUserId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(ZhenHuanThirdProcessModule.class).getAllUser(activityId, targetUserId);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            ZhenHuanProto.ZhenHuanThirdProcessGetAllUserRespMsg.Builder respMsg = ZhenHuanProto.ZhenHuanThirdProcessGetAllUserRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_ZHENHUAN_THIRD_PROCESS_GET_ALL_USER, respMsg);
        }
    }
}
